//
//  languagesTableViewDelegator.m
//  LanguagesTeach
//
//  Created by Niel Santos on 12/16/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//


#import "LanguagesTableViewDelegator.h"
#import "RowTableCell.h"
#import "SubjectPath.h"
#import "LevelsController.h"


@implementation LanguagesTableViewDelegator

@synthesize navigationController;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
	RowTableCell *cell =nil;
	SubjectPath *subjectPath = nil;
	LevelsController *levelsController =nil;
	
	
	cell = (RowTableCell*)[tableView cellForRowAtIndexPath:indexPath];
	subjectPath = [[SubjectPath alloc] init];
	subjectPath.languagePrefix = [cell prefix];
	
	if (levelsController ==nil) {
		levelsController = [[LevelsController alloc] initWithNibName:@"Languages" bundle:nil];
	}
	
	levelsController.subjectPath = subjectPath;
	
	// Pass the selected object to the new view controller.
	[self.navigationController pushViewController:levelsController animated:YES];
	[tableView deselectRowAtIndexPath:indexPath animated:YES];
	[levelsController release];
	[subjectPath release];
}

@end
